package it.polimi.swimv2.remote;

import it.polimi.swimv2.entities.HelpRequest;
import it.polimi.swimv2.exception.HelpRequestException;

import java.util.Collection;

import javax.ejb.Remote;

@Remote
public interface HelpRequestManagerRemote {

	/**
	 * Returns the received help requests
	 * 
	 * @param username
	 * @return
	 * @throws HelpRequestException
	 *             when parameters are not valid
	 */
	public Collection<HelpRequest> getReceivedHelpRequest(String username)
			throws HelpRequestException;

	/**
	 * Returns the sent help requests
	 * 
	 * @param username
	 * @return
	 * @throws HelpRequestException
	 *             when parameters are invalid
	 */
	public Collection<HelpRequest> getSentHelpRequest(String username)
			throws HelpRequestException;

	/**
	 * returns the help request specified by its id
	 * 
	 * @param id
	 * @return
	 */
	public HelpRequest getHelpRequest(Integer id);

	/**
	 * Accept a specified help request.
	 * 
	 * @param username
	 *            the user who is accepting the request
	 * @param helpId
	 *            the id of the request
	 * @throws HelpRequestException
	 *             when parameter are not valid
	 */
	public void acceptHelp(String username, Integer helpId)
			throws HelpRequestException;

	/**
	 * Refuses a specified help request.
	 * 
	 * @param username
	 *            the user who is refusing the request
	 * @param helpId
	 *            the id of the request
	 * @throws HelpRequestException
	 *             when parameters are not valid
	 */
	public void refuseHelp(String username, Integer helpId)
			throws HelpRequestException;

	/**
	 * Deletes a specified help request.
	 * 
	 * @param username
	 *            the user who is deleting the request.
	 * @param helpId
	 *            the id of the request
	 * @throws HelpRequestException
	 *             when parameters are not valid
	 */
	public void deleteHelp(String username, Integer helpId)
			throws HelpRequestException;

	/**
	 * Change the visibility status of the specified help request. When it is
	 * not visible to both the sender and receiver, it is removed from the
	 * database.
	 * 
	 * @param helpId
	 * @param username
	 * @throws HelpRequestException
	 */
	public void removeHelpRequest(Integer helpId, String username)
			throws HelpRequestException;

	/**
	 * Sends a new help request.
	 * 
	 * @param sender
	 * @param receiver
	 * @param requiredAbility
	 * @param object
	 * @return the id of the sent request.
	 * @throws HelpRequestException
	 */
	public int sendHelpRequest(String sender, String receiver,
			String requiredAbility, String object) throws HelpRequestException;

	/**
	 * Attaches a new message to the specified request.
	 * 
	 * @param senderUsername
	 *            the user who is sending the message.
	 * @param helpId
	 *            the id of the request
	 * @param content
	 *            the string content of the message.
	 * @throws HelpRequestException
	 *             when parameters are not valid
	 */
	public void attachMessage(String senderUsername, Integer helpId,
			String content) throws HelpRequestException;
}
